<!DOCTYPE html>
<html lang="en">
<head>
  <title>浩然金融中心管理平台</title>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"
        name="viewport">
  <#include "/common/csslib.html">
</head>
<body>
<div class="main-wrapper">
  <!-- start: MAIN CONTAINER -->
  <div class="main-container inner">
    <!-- start: PAGE -->
    <div class="main-content">
      <div class="container">
        <div class="row h-home-path">
          <div class="col-md-12">
            <ol class="breadcrumb">
              <li><i class="fa fa-home"></i>&nbsp;&nbsp;所在位置</li>
              <li>首页</li>
              <li class="active">编辑表模型信息</li>
            </ol>
          </div>
        </div>
        <div class="row h-main-search">
          <form action="javascript:;" method="post">
            <div class="pull-right h-btn-group">
              <button class="btn btn-info" id="return-btn" onclick="SystemTableInfoMgr.returnIndex()"><i
                      class="fa fa-mail-reply">&nbsp;&nbsp;</i>返回
              </button>
              <button class="btn btn-info" id="save" onclick="SystemTableInfoMgr.submitForm()" type="button"><i
                      class="fa fa-save">&nbsp;&nbsp;</i>保存
              </button>
            </div>
          </form>
        </div>

        <div class="form-horizontal  h-form-warp">
          <div class="h-msg-title h-table-header">
            <strong>表模型信息</strong>
          </div>
          <form action="/systemTableInfo/saveSystemTableInfo" class="form-horizontal" id="systemTableInfoForm"
                method="post" role="form">
            <input id="operation" name="operation" type="hidden" value="${operation!}"/>
            <input id="id" name="id" type="hidden" value="${systemTableInfo.id!}"/>
            <input class="form-control" id="moduleId" name="moduleId" type="hidden"
                   value="${systemTableInfo.moduleId!}"/>
            <div class="form-group">
              <label class="col-sm-2 control-label">表编码：</label>
              <div class="col-sm-6">
                <input class="form-control" id="tableCode" name="tableCode"
                       onblur="SystemTableInfoMgr.changeEntityCode()"
                       required="required" type="text"
                       value="${systemTableInfo.tableCode!}"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">表编码映射：</label>
              <div class="col-sm-6">
                <input class="form-control" id="tableCodeMapping" name="tableCodeMapping"
                       onblur="SystemTableInfoMgr.changeEntityCodeMapping()"
                       type="text"
                       value="${systemTableInfo.tableCodeMapping!}"/>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">表名称：</label>
              <div class="col-sm-6">
                <input class="form-control" id="tableName" name="tableName" required="required"
                       type="text" value="${systemTableInfo.tableName!}"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">表对应实体类编码：</label>
              <div class="col-sm-6">
                <input class="form-control" id="tableEntityCode" name="tableEntityCode" readonly="readonly"
                       required="required" type="text" value="${systemTableInfo.tableEntityCode!}"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">表对应实体类编码映射：</label>
              <div class="col-sm-6">
                <input class="form-control" id="tableEntityCodeMapping" name="tableEntityCodeMapping"
                       readonly="readonly"
                       type="text" value="${systemTableInfo.tableEntityCodeMapping!}"/>
              </div>
            </div>
            <!-- <div class="form-group">
              <label class="col-sm-2 control-label">表的主键：</label>
              <div class="col-sm-6">
                <input type="text" id="pkId" name="pkId" class="form-control" value="${systemTableInfo.pkId!}" readonly="readonly"/>
              </div>
            </div> -->
          </form>
        </div>
      </div>
    </div>
    <!-- end: PAGE -->
  </div>
  <!-- end: MAIN CONTAINER -->
</div>
<#include "/common/jslib.html">
<!-- form页面js -->
<script type="text/javascript">
    $(function () {
        // 页面操作类型：add(添加)-edit(编辑)-view(查看)
        var operation = $("#operation").val();
        SystemTableInfoMgr = {
            // 初始化
            init: function () {
                // 查看的时候不显示保存按钮
                if (operation == "view") {
                    Jmts.setFormReadOnly();
                    $("#save").hide();
                }
                initAmtAndRate();//初始化金额以及利率
            },
            // init end

            // 提交数据
            submitForm: function () {
                Jmts.convertAmtAndRate();//反格式化金额和利率，以防保存出错
                Jmts.ajaxSubmit(document.getElementById("systemTableInfoForm"), function (result) {
                    var operation = result.operation;
                    if (result.success) {
                        Jmts.succTips(result.msg);
                        if (operation == 'add') {
                            SystemTableInfoMgr.returnIndex();
                        } else if (operation == 'edit') {
                            window.location.reload();
                        }
                    } else {
                        Jmts.errorTips(result.msg);
                        Jmts.revertAmtAndRate();
                    }
                });
                return false;
            },
            // submitForm end
            //返回
            returnIndex: function () {
                var moduleId = $("#moduleId").val();
                window.location.href = "/systemTableInfo/query?moduleId=" + moduleId;
            },
            changeEntityCode: function () {
                var tableCode = $("#tableCode").val();
                sb = new StringBuilder("");
                if (tableCode != null && tableCode != '' && tableCode != 'undefined') {
                    var tableCodeArray = tableCode.split("_");
                    for (var i in tableCodeArray) {
                        sb.append(tableCodeArray[i].substring(0, 1).toUpperCase() + tableCodeArray[i].substring(1));
                    }
                    $("#tableEntityCode").val(sb.toString());
                }
            },
            changeEntityCodeMapping: function () {
                var tableCode = $("#tableCodeMapping").val();
                sb = new StringBuilder("");
                if (tableCode != null && tableCode != '' && tableCode != 'undefined') {
                    var tableCodeArray = tableCode.split("_");
                    for (var i in tableCodeArray) {
                        sb.append(tableCodeArray[i].substring(0, 1).toUpperCase() + tableCodeArray[i].substring(1));
                    }
                    $("#tableEntityCodeMapping").val(sb.toString());
                }
            }
        };
        // 执行初始化
        SystemTableInfoMgr.init();
        // 前台验证表单
        $("#systemTableInfoForm").validate();
    });
</script>
</body>
</html>
